package com.xhd.db;

import java.io.File;
import java.io.FileInputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import com.xhd.base.log.Log;
import com.xhd.base.log.LogFactory;
import com.xhd.base.session.SessionUserInfo;
import com.xhd.base.util.xBaseObj;
import com.xhd.config.BizObjClass;
import com.xhd.exception.DatabaseException;
import com.xhd.exception.XException;
import com.xhd.server.ServerConfig;
import com.xhd.util.DataFormat;
import com.xhd.xml.XMLSerializer;

	public class BizObjStoreListener
	{
	  private static final int jm412 = 0;
	  private static final int jm413 = 1;
	  private static final int jm414 = 2;
	  private static final int jm415 = 3;
	  private static final int jm416 = 4;
	  private boolean jm417 = true;
	  private boolean jm418 = true;
	  private boolean jm419 = true;
	  private static final Log jm9;
	  private static BizObjStoreListener jm62;
	  private StoreActions[] jm420 = null;
	  private static HashMap jm421;
	  private BizObjStoreEventListener jm422 = null;
	  static Class jm10;

	  static
	  {
	    Class tmp3_0 = jm10;
	    if (tmp3_0 == null)
	    {
	     
	      try
	      {
	        BizObjStoreListener.jm10 = Class.forName("com.sinocc.systemdbmanager.BizObjStoreListener");
	      }
	      catch (ClassNotFoundException localClassNotFoundException)
	      {
	        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
	      }
	    }
	    jm9 = LogFactory.getLog(tmp3_0);
	    jm62 = null;
	    jm421 = null;
	  }

	  private StoreAction[] jm409(int paramInt, BizObjClass paramBizObjClass, SessionUserInfo paramSessionUserInfo)
	  {
	    if (paramBizObjClass == null)
	      return null;
	    StoreAction[] arrayOfStoreAction = this.jm420[paramInt].getActions(paramBizObjClass);
	    if (arrayOfStoreAction == null)
	      return null;
	    Vector localVector = null;
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      if (!(arrayOfStoreAction[i].isCondition(paramSessionUserInfo)))
	      {
	        localVector = new Vector();
	        for (int j = 0; j < i; ++j)
	          localVector.add(arrayOfStoreAction[j]);
	      }
	      else
	      {
	        if (localVector == null)
	          continue;
	        localVector.add(arrayOfStoreAction[i]);
	      }
	    if (localVector != null)
	    {
	      arrayOfStoreAction = new StoreAction[localVector.size()];
	      for ( int i = 0; i < arrayOfStoreAction.length; ++i)
	        arrayOfStoreAction[i] = ((StoreAction)localVector.get(i));
	    }
	    return arrayOfStoreAction;
	  }

	  public static BizObjStoreListener getInstance()
	  {
	    if (jm62 == null)
	      try
	      {
	        jm62 = new BizObjStoreListener();
	      }
	      catch (DatabaseException localDatabaseException)
	      {
	        jm62 = null;
	        jm9.fatal(localDatabaseException);
	      }
	    return jm62;
	  }

	  private BizObjStoreListener()
	    throws DatabaseException
	  {
	    for (int i = 0; i < this.jm420.length; ++i)
	      this.jm420[i] = new StoreActions(i);
	    this.jm417 = jm117();
	  }

	  public void onInsert(xBaseObj paramxBaseObj, Map paramMap)
	    throws DatabaseException
	  {
	    if (this.jm422 != null)
	      this.jm422.onInsert(paramxBaseObj);
	    if ((!(this.jm417)) || (paramxBaseObj == null))
	      return;
	    BizObjProxy localBizObjProxy = new BizObjProxy(paramxBaseObj);
	    StoreAction[] arrayOfStoreAction = jm409(0, localBizObjProxy.getBizClass(), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return;
	    try
	    {
	      for (int i = 0; i < arrayOfStoreAction.length; ++i)
	        arrayOfStoreAction[i].setProp(localBizObjProxy, paramMap);
	    }
	    catch (XException localSinocpcException)
	    {
	      throw new DatabaseException(localSinocpcException);
	    }
	  }

	  public DBWhereExp onDelete(xBaseObj paramxBaseObj)
	    throws DatabaseException
	  {
	    if (this.jm422 != null)
	      this.jm422.onDelete(paramxBaseObj);
	    if ((!(this.jm417)) || (paramxBaseObj == null))
	      return null;
	    StoreAction[] arrayOfStoreAction = jm409(1, BizObjClass.getInstance(paramxBaseObj), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	    return localDBWhereExp;
	  }

	  public DBWhereExp onUpdate(xBaseObj paramxBaseObj, BizObjFields paramBizObjFields)
	    throws DatabaseException
	  {
	    if (this.jm422 != null)
	      this.jm422.onUpdate(paramxBaseObj, paramBizObjFields);
	    if ((!(this.jm417)) || (paramxBaseObj == null))
	      return null;
	    StoreAction[] arrayOfStoreAction = jm409(2, BizObjClass.getInstance(paramxBaseObj), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	    {
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	      arrayOfStoreAction[i].ignoreUpdate(paramBizObjFields);
	    }
	    return localDBWhereExp;
	  }

	  public DBWhereExp onSelect(xBaseObj paramxBaseObj)
	    throws DatabaseException
	  {
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramxBaseObj.isIgnoreDaoQueryRule()))
	      return null;
	    StoreAction[] arrayOfStoreAction = jm409(3, BizObjClass.getInstance(paramxBaseObj), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	    return localDBWhereExp;
	  }

	  public DBWhereExp onSearch(xBaseObj paramxBaseObj)
	    throws DatabaseException
	  {
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramxBaseObj.isIgnoreDaoQueryRule()))
	      return null;
	    StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance(paramxBaseObj), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	    return localDBWhereExp;
	  }

	  public String onExecuteSQL(xBaseObj paramxBaseObj, String paramString, int paramInt)
	    throws DatabaseException
	  {
	    if (!(this.jm419))
	      return paramString;
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramString == null) || (paramString.length() < 7))
	      return paramString;
	    if ("insert ".equals(paramString.substring(0, 7).toLowerCase()))
	      return paramString;
	    String str = SQLAnalyzer.getTable(paramString);
	    StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance(str), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return paramString;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	    if (!(localDBWhereExp.isNull()))
	      return SQLAnalyzer.addExecuteWhere(paramString, localDBWhereExp.toSQL(paramInt));
	    return paramString;
	  }

	  public void onExecuteSQL(xBaseObj paramxBaseObj, DBSQL paramDBSQL, int paramInt)
	    throws DatabaseException
	  {
	    if (!(this.jm419))
	      return;
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramDBSQL == null) || (paramDBSQL.length() < 7))
	      return;
	    String str1 = paramDBSQL.getSQL();
	    if ("insert ".equals(str1.substring(0, 7).toLowerCase()))
	      return;
	    String str2 = SQLAnalyzer.getTable(str1);
	    StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance(str2), paramxBaseObj.getUserInfo());
	    if (arrayOfStoreAction == null)
	      return;
	    DBWhereExp localDBWhereExp = new DBWhereExp(null);
	    for (int i = 0; i < arrayOfStoreAction.length; ++i)
	      arrayOfStoreAction[i].addWhere(paramxBaseObj, localDBWhereExp, null);
	    if (localDBWhereExp.isNull())
	      return;
	    SQLAnalyzer.addExecuteWhere(paramDBSQL, paramInt, localDBWhereExp);
	  }

	  public void onQuery(xBaseObj paramxBaseObj, DBQuery paramDBQuery)
	    throws DatabaseException
	  {
	    if (!(this.jm418))
	      return;
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramDBQuery == null) || (paramDBQuery.isProcedure()) || (paramDBQuery.isIgnoreDaoRule()))
	      return;
	    if ((paramxBaseObj != null) && (paramxBaseObj.isIgnoreDaoQueryRule()))
	      return;
	    Vector localVector1 = paramDBQuery.getAllQuery();
	    for (int i = 0; i < localVector1.size(); ++i)
	    {
	      paramDBQuery = (DBQuery)localVector1.get(i);
	      Vector localVector2 = paramDBQuery.getTables(true);
	      if (localVector2 == null)
	        continue;
	      DBWhereExp localDBWhereExp1 = new DBWhereExp(null);
	      for (int j = 0; j < localVector2.size(); ++j)
	      {
	        String str = (String)localVector2.get(j);
	        StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance(str), paramxBaseObj.getUserInfo());
	        if (arrayOfStoreAction == null)
	          continue;
	        for (int k = 0; k < arrayOfStoreAction.length; ++k)
	          arrayOfStoreAction[k].addWhere(paramxBaseObj, localDBWhereExp1, SQLAnalyzer.getAlias(str));
	      }
	      if (localDBWhereExp1.isNull())
	        continue;
	      DBWhereExp localDBWhereExp2 = paramDBQuery.getWhere();
	      if ((localDBWhereExp2 != null) && (!(localDBWhereExp2.isNull())))
	        localDBWhereExp1.andSubExp(localDBWhereExp2);
	      paramDBQuery.clearWhere();
	      paramDBQuery.andExp(localDBWhereExp1);
	    }
	  }

	  public String onQuery(xBaseObj paramxBaseObj, String paramString, int paramInt)
	    throws DatabaseException
	  {
	    if (!(this.jm418))
	      return paramString;
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramString == null) || (paramString.length() < 7))
	      return paramString;
	    if ((paramxBaseObj != null) && (paramxBaseObj.isIgnoreDaoQueryRule()))
	      return paramString;
	    if (!("select ".equals(paramString.substring(0, 7).toLowerCase())))
	      return paramString;
	    Vector localVector1 = SQLAnalyzer.splitUnionSQL(paramString);
	    StringBuffer localStringBuffer = new StringBuffer(paramString.length() + 16);
	    for (int i = 0; i < localVector1.size(); ++i)
	    {
	      if (i > 0)
	        localStringBuffer.append(" UNION ");
	      paramString = (String)localVector1.get(i);
	      Vector localVector2 = SQLAnalyzer.getTables(paramString, true);
	      if (localVector2 == null)
	      {
	        localStringBuffer.append(paramString);
	      }
	      else
	      {
	        DBWhereExp localDBWhereExp = new DBWhereExp(null);
	        Object localObject;
	        for (int j = 0; j < localVector2.size(); ++j)
	        {
	          localObject = (String)localVector2.get(j);
	          StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance((String)localObject), paramxBaseObj.getUserInfo());
	          if (arrayOfStoreAction == null)
	            continue;
	          for (int k = 0; k < arrayOfStoreAction.length; ++k)
	            arrayOfStoreAction[k].addWhere(paramxBaseObj, localDBWhereExp, SQLAnalyzer.getAlias((String)localObject));
	        }
	        if (!(localDBWhereExp.isNull()))
	        {
	          DBQuery localDBQuery = SQLAnalyzer.sqlToQuery(paramString);
	          localObject = localDBQuery.getWhere();
	          if ((localObject != null) && (!(((DBWhereExp)localObject).isNull())))
	            localDBWhereExp.andSubExp((DBWhereExp)localObject);
	          localDBQuery.clearWhere();
	          localDBQuery.andExp(localDBWhereExp);
	          localStringBuffer.append(localDBQuery.toSQL(paramInt));
	        }
	        else
	        {
	          localStringBuffer.append(paramString);
	        }
	      }
	    }
	    return ((String)localStringBuffer.toString());
	  }

	  public void onQuery(xBaseObj paramxBaseObj, DBSQL paramDBSQL, int paramInt)
	    throws DatabaseException
	  {
	    if (!(this.jm418))
	      return;
	    if ((!(this.jm417)) || (paramxBaseObj == null) || (paramDBSQL == null) || (paramDBSQL.length() < 7))
	      return;
	    if ((paramxBaseObj != null) && (paramxBaseObj.isIgnoreDaoQueryRule()))
	      return;
	    if (!("select ".equals(paramDBSQL.getSQL().substring(0, 7).toLowerCase())))
	      return;
	    Vector localVector1 = SQLAnalyzer.splitUnionSQL(paramDBSQL.getSQL());
	    StringBuffer localStringBuffer = new StringBuffer(paramDBSQL.length() + 16);
	    for (int i = 0; i < localVector1.size(); ++i)
	    {
	      if (i > 0)
	        localStringBuffer.append(" UNION ");
	      String str = (String)localVector1.get(i);
	      Vector localVector2 = SQLAnalyzer.getTables(str, true);
	      if (localVector2 == null)
	      {
	        localStringBuffer.append(str);
	      }
	      else
	      {
	        DBWhereExp localDBWhereExp = new DBWhereExp(null);
	        Object localObject;
	        for (int j = 0; j < localVector2.size(); ++j)
	        {
	          localObject = (String)localVector2.get(j);
	          StoreAction[] arrayOfStoreAction = jm409(4, BizObjClass.getInstance((String)localObject), paramxBaseObj.getUserInfo());
	          if (arrayOfStoreAction == null)
	            continue;
	          for (int k = 0; k < arrayOfStoreAction.length; ++k)
	            arrayOfStoreAction[k].addWhere(paramxBaseObj, localDBWhereExp, SQLAnalyzer.getAlias((String)localObject));
	        }
	        if (!(localDBWhereExp.isNull()))
	        {
	          DBQuery localDBQuery = SQLAnalyzer.sqlToQuery(str);
	          localObject = localDBQuery.getWhere();
	          if ((localObject != null) && (!(((DBWhereExp)localObject).isNull())))
	            localDBWhereExp.andSubExp((DBWhereExp)localObject);
	          localDBQuery.clearWhere();
	          localDBQuery.andExp(localDBWhereExp);
	          localStringBuffer.append(localDBQuery.toSQL(paramInt));
	        }
	        else
	        {
	          localStringBuffer.append(str);
	        }
	      }
	    }
	    paramDBSQL.setSQL(localStringBuffer.toString());
	  }

	  void jm410()
	  {
	    if (this.jm422 == null)
	      return;
	    this.jm422.onCommit();
	  }

	  void jm411()
	  {
	    if (this.jm422 == null)
	      return;
	    this.jm422.onRollback();
	  }

	  private boolean jm117()
	    throws DatabaseException
	  {
	    try
	    {
	      XMLSerializer localXMLSerializer = null;
	      Vector localVector1 = null;
	      Vector localVector2 = null;
	      Vector localVector3 = null;
	      Vector localVector4 = ServerConfig.getConfFiles("daorule");
	      Vector localVector5 = null;
	      int i;
	      Object localObject1;
	      Object localObject2;
	      if ((localVector4 != null) && (localVector4.size() > 0))
	      {
	        localVector1 = new Vector(8);
	        localVector2 = new Vector(8);
	        localVector3 = new Vector();
	        localVector5 = new Vector();
	        for (i = 0; i < localVector4.size(); ++i)
	        {
	          String str1 = (String)localVector4.get(i);
	          localObject1 = new File(str1);
	          if ((!(((File)localObject1).exists())) && (!(((File)localObject1).isFile())))
	            continue;
	          FileInputStream localFileInputStream = new FileInputStream((File)localObject1);
	          localXMLSerializer = new XMLSerializer(localFileInputStream, false);
	          localObject2 = localXMLSerializer.getCollection("rule");
	          if (localObject2 != null)
	            localVector1.addAll((Collection)localObject2);
	          localObject2 = localXMLSerializer.getCollection("action");
	          if (localObject2 != null)
	            localVector2.addAll((Collection)localObject2);
	          localObject2 = localXMLSerializer.getCollection("class-group");
	          if (localObject2 != null)
	            localVector3.addAll((Collection)localObject2);
	          String str2 = localXMLSerializer.getData("support-query-sql");
	          if ((str2 != null) && (str2.length() > 0))
	            this.jm418 = "true".equalsIgnoreCase(str2);
	          str2 = localXMLSerializer.getData("support-execute-sql");
	          if ((str2 != null) && (str2.length() > 0))
	            this.jm419 = "true".equalsIgnoreCase(str2);
	          localObject2 = localXMLSerializer.getCollection("event-listener");
	          if (localObject2 != null)
	            localVector5.addAll((Collection)localObject2);
	          localFileInputStream.close();
	        }
	      }
	      int j;
	      if ((localVector5 != null) && (localVector5.size() > 0))
	      {
	        jm9.info("DaoRule listener size: " + localVector5.size());
	        i = localVector5.size();
	        j = 0;
	        while (j < i)
	        {
	          localObject1 = (Map)localVector5.get(j);
	          localObject2 = (String)((Map)localObject1).get("class");
	          try
	          {
	            this.jm422 = ((BizObjStoreEventListener)Class.forName((String)localObject2).getMethod("getInstance", null).invoke(null, null));
	          }
	          catch (Exception localException2)
	          {
	            jm9.error("DaoRule listener:", localException2);
	            ++j;
	          }
	        }
	      }
	      if ((localVector1 != null) && (localVector1.size() > 0) && (localVector2 != null) && (localVector2.size() > 0))
	      {
	        i = (localVector3 != null) ? localVector3.size() : 0;
	        if (i > 0)
	          jm421 = new HashMap(i);
	        Object localObject3;
	        String[] localObject4;
	        Object localObject5;
	        for (j = 0; j < i; ++j)
	        {
	          localObject1 = (Map)localVector3.get(j);
	          localObject2 = (String)((Map)localObject1).get("group-id");
	          localObject3 = (String)((Map)localObject1).get("class-names");
	          localObject4 = DataFormat.splitString((String)localObject3, false);
	          localObject5 = new HashMap(localObject4.length);
	          for (int i1 = 0; i1 < localObject4.length; ++i1)
	            ((HashMap)localObject5).put(((String) localObject4[i1]).trim().toLowerCase(), "2");
	          jm421.put(localObject2, localObject5);
	        }
	        i = localVector2.size();
	        HashMap localHashMap1 = new HashMap(i);
	        for (int k = 0; k < i; ++k)
	        {
	          localObject2 = new HashMap();
	          ((HashMap)localObject2).putAll((Map)localVector2.get(k));
	          localObject3 = (String)((HashMap)localObject2).get("action-id");
	          if ((localObject3 == null) || (((String)localObject3).length() < 1))
	          {
	            jm9.warn("Invalid DaoRule action: " + k);
	          }
	          else
	          {
	            localObject3 = ((String)localObject3).trim().toLowerCase();
	            if (localHashMap1.containsKey(localObject3))
	              jm9.warn("DaoRule action " + ((String)localObject3) + " repeat!");
	            localHashMap1.put(localObject3, localObject2);
	          }
	        }
	        i = localVector1.size();
	        HashMap localHashMap2 = new HashMap(i);
	        for (int l = 0; l < i; ++l)
	        {
	          localObject3 = new HashMap();
	          ((HashMap)localObject3).putAll((Map)localVector1.get(l));
	          localObject4 = (String[])((HashMap)localObject3).get("rule-id");
	          if ((localObject4 == null) || (((String[])localObject4).length < 1))
	          {
	            jm9.warn("Invalid DaoRule rule: " + l);
	          }
	          else
	          {
	             localObject4 =  localObject4.trim().toLowerCase();
	            if (localHashMap2.containsKey(localObject4))
	              jm9.warn("DaoRule rule '" + ((String)localObject4) + "' repeat!");
	            localObject5 = (String)((HashMap)localObject3).get("action-id");
	            Map localMap = null;
	            if (localObject5 != null)
	              localMap = (Map)localHashMap1.get(localObject5);
	            if (localMap == null)
	            {
	              jm9.warn("Invalid DaoRule rule '" + ((String[])localObject4) + "' action invalid!");
	            }
	            else
	            {
	              String str3 = (String)((HashMap)localObject3).get("event");
	              if (str3 == null)
	                continue;
	              if (str3.length() < 1)
	                continue;
	              localHashMap2.put(localObject4, localObject3);
	              localMap.put("matcher", ((HashMap)localObject3).get("matcher"));
	              if (((HashMap)localObject3).containsKey("condition"))
	                localMap.put("condition", ((HashMap)localObject3).get("condition"));
	              str3 = str3.trim().toLowerCase();
	              if ("*".equals(str3))
	              {
	                for (int i2 = 0; i2 < this.jm420.length; ++i2)
	                  this.jm420[i2].addAction(localMap);
	              }
	              else if (str3.indexOf("insert") >= 0)
	              {
	                this.jm420[0].addAction(localMap);
	              }
	              else if (str3.indexOf("delete") >= 0)
	              {
	                this.jm420[1].addAction(localMap);
	              }
	              else if (str3.indexOf("update") >= 0)
	              {
	                this.jm420[2].addAction(localMap);
	              }
	              else if (str3.indexOf("select") >= 0)
	              {
	                this.jm420[3].addAction(localMap);
	              }
	              else
	              {
	                if (str3.indexOf("search") < 0)
	                  continue;
	                this.jm420[4].addAction(localMap);
	              }
	            }
	          }
	        }
	        jm9.info("DaoRule action size: " + localHashMap1.size());
	        jm9.info("DaoRule rule size: " + localHashMap2.size());
	        localHashMap2.clear();
	        localHashMap2 = null;
	        localHashMap1.clear();
	        localHashMap1 = null;
	        return true;
	      }
	      return false;
	    }
	    catch (Exception localException1)
	    {
	      jm9.fatal(localException1);
	      throw new DatabaseException(10064, "daorule", localException1.getMessage());
	    }
	  }

	  static Log jm4()
	  {
	    return jm9;
	  }

	  static HashMap jm5()
	  {
	    return jm421;
	  }

	  public static class StoreAction
	  {
	    private String jm572;
	    private String jm573;
	    private boolean jm574 = true;
	    private boolean jm575 = false;
	    private String[] jm576;
	    private String[] jm577;
	    private String[] jm578;
	    private boolean jm579 = false;
	    private Class jm580 = null;
	    private String jm581 = null;
	    private Map jm582 = null;
	    private boolean jm583 = false;
	    private String jm584 = null;
	    private String jm585 = null;

	    public StoreAction(Map paramMap)
	      throws DatabaseException
	    {
	      this.jm573 = ((String)paramMap.get("add-where-sql"));
	      if ((this.jm573 != null) && (this.jm573.length() < 1))
	        this.jm573 = null;
	      this.jm572 = ((String)paramMap.get("add-where-values"));
	      if ((this.jm572 != null) && (this.jm572.length() < 1))
	        this.jm572 = null;
	      String str = (String)paramMap.get("set-prop");
	      if ((str != null) && (str.length() > 0))
	      {
	        this.jm575 = true;
	        String[] localObject = DataFormat.splitString(str, ',');
	        this.jm576 = new String[localObject.length];
	        this.jm577 = new String[localObject.length];
	        for (int i = 0; i < localObject.length; ++i)
	        {
	          int k = localObject[i].indexOf(61);
	          if (k <= 0)
	            continue;
	          if (k == localObject[i].length() - 1)
	            continue;
	          this.jm576[i] = localObject[i].substring(0, k).toLowerCase();
	          this.jm577[i] = localObject[i].substring(k + 1);
	        }
	      }
	      str = (String)paramMap.get("ignore-update");
	      if ((str != null) && (str.length() > 0))
	      {
	        str = str.toLowerCase();
	        this.jm578 = DataFormat.splitString(str, ',');
	      }
	      Object localObject = (String)paramMap.get("matcher");
	      if ((localObject == null) || (((String)localObject).length() < 2))
	      {
	        this.jm574 = true;
	      }
	      else
	      {
	        this.jm574 = false;
	        this.jm579 = ('!' == ((String)localObject).charAt(0));
	        if (this.jm579)
	          localObject = ((String)localObject).substring(1);
	        if (':' == ((String)localObject).charAt(0))
	          try
	          {
	            this.jm580 = Class.forName(((String)localObject).substring(1));
	          }
	          catch (ClassNotFoundException localClassNotFoundException)
	          {
	            BizObjStoreListener.jm4().fatal(localClassNotFoundException);
	            throw new DatabaseException();
	          }
	        else if ('@' == ((String)localObject).charAt(0))
	          this.jm582 = ((Map)BizObjStoreListener.jm5().get(((String)localObject).substring(1)));
	        else
	          this.jm581 = ((String)localObject);
	      }
	      str = (String)paramMap.get("condition");
	      if ((str == null) || (str.length() <= 0))
	        return;
	      int j = str.indexOf("<>");
	      if (j > 0)
	      {
	        this.jm583 = true;
	        this.jm584 = str.substring(0, j);
	        this.jm585 = str.substring(j + 2);
	      }
	      else
	      {
	        j = str.indexOf(61);
	        this.jm583 = false;
	        this.jm584 = str.substring(0, j);
	        this.jm585 = str.substring(j + 1);
	      }
	    }

	    public boolean isMatch(BizObjClass paramBizObjClass)
	    {
	      if (this.jm574)
	        return true;
	      boolean bool = false;
	      if (this.jm580 != null)
	        bool = this.jm580.isAssignableFrom(paramBizObjClass.getBizClass());
	      if (this.jm582 != null)
	        bool = this.jm582.containsKey(paramBizObjClass.getName());
	      else if ('.' == this.jm581.charAt(0))
	        bool = paramBizObjClass.getFullName().indexOf(this.jm581) > 0;
	      else
	        bool = paramBizObjClass.getFullName().startsWith(this.jm581);
	      if (this.jm579)
	        return (!(bool));
	      return bool;
	    }

	    public boolean isCondition(SessionUserInfo paramSessionUserInfo)
	    {
	      if (this.jm584 == null)
	        return true;
	      if (paramSessionUserInfo == null)
	        return this.jm583;
	      boolean bool = false;
	      Object localObject = paramSessionUserInfo.getProperty(this.jm584);
	      if (localObject != null)
	        bool = this.jm585.equals(localObject.toString());
	      return ((this.jm583) ? true : (bool) ? false : bool);
	    }

	    public void setProp(BizObjProxy paramBizObjProxy, Map paramMap)
	      throws XException
	    {
	      for (int i = 0; i < this.jm576.length; ++i)
	      {
	        if (this.jm576[i] == null)
	          continue;
	        String str = this.jm577[i];
	        if ('@' == str.charAt(0))
	          str = paramBizObjProxy.getEnv(str).toString();
	        if (paramMap != null)
	          paramMap.put(this.jm576[i], str);
	        else
	          paramBizObjProxy.setFieldValue(this.jm576[i], str);
	      }
	    }

	    public boolean hasAddWhere()
	    {
	      return (this.jm573 != null);
	    }

	    public void addWhere(xBaseObj paramxBaseObj, DBWhereExp paramDBWhereExp, String paramString)
	      throws DatabaseException
	    {
	      if (this.jm573 == null)
	        return;
	      try
	      {
	        if (this.jm572 == null)
	        {
	          paramDBWhereExp.and(new DBWhereExp(this.jm573));
	          return;
	        }
	        BizObjProxy localBizObjProxy = new BizObjProxy(paramxBaseObj);
	        String[] arrayOfString = DataFormat.splitString(this.jm572, ',');
	        Object[] arrayOfObject = new Object[arrayOfString.length];
	        for (int i = 0; i < arrayOfString.length; ++i)
	          if ('@' == arrayOfString[i].charAt(0))
	            arrayOfObject[i] = localBizObjProxy.getEnv(arrayOfString[i]);
	          else
	            arrayOfObject[i] = localBizObjProxy.getValue(arrayOfString[i]);
	        if (paramString == null)
	          paramString = "";
	        else
	          paramString = paramString + ".";
	        String str = this.jm573.replaceAll("@alias.", paramString);
	        paramDBWhereExp.and(DBWhereExp.custom(str, arrayOfObject));
	      }
	      catch (XException localSinocpcException)
	      {
	        throw new DatabaseException(localSinocpcException);
	      }
	    }

	    public void ignoreUpdate(BizObjFields paramBizObjFields)
	    {
	      if ((paramBizObjFields == null) || (this.jm578 == null))
	        return;
	      for (int i = 0; i < this.jm578.length; ++i)
	        paramBizObjFields.remove(this.jm578[i]);
	    }

	    static boolean jm4(StoreAction paramStoreAction)
	    {
	      return paramStoreAction.jm575;
	    }
	  }

	  public class StoreActions
	  {
	    private int jm548;
	    private boolean jm549 = false;
	    private Vector jm550 = new Vector(8);
	    private int jm551 = 0;
	    private HashMap jm321 = new HashMap(256);

	    public StoreActions(int paramInt)
	    {
	      this.jm548 = paramInt;
	    }

	    public int getCount()
	    {
	      return this.jm551;
	    }

	    public void addAction(Map paramMap)
	      throws DatabaseException
	    {
	      StoreAction localStoreAction = new BizObjStoreListener.StoreAction(BizObjStoreListener.this, paramMap);
	      switch (this.jm548)
	      {
	      case 0:
	        if (!(BizObjStoreListener.StoreAction.jm4(localStoreAction)))
	          return;
	        break;
	      case 1:
	        if (!(localStoreAction.hasAddWhere()))
	          return;
	        break;
	      case 2:
	        break;
	      case 3:
	        if (!(localStoreAction.hasAddWhere()))
	          return;
	        break;
	      case 4:
	        if (!(localStoreAction.hasAddWhere()))
	          return;
	      }
	      this.jm549 = true;
	      this.jm550.add(localStoreAction);
	      this.jm551 += 1;
	    }

	    public StoreAction[] getActions(BizObjClass paramBizObjClass)
	    {
	      if (!(this.jm549))
	        return null;
	      if (this.jm321.containsKey(paramBizObjClass))
	        return ((StoreAction[])this.jm321.get(paramBizObjClass));
	      Vector localVector = new Vector(4);
	      for (int i = 0; i < this.jm551; ++i)
	      {
	      Object  localObject = (StoreAction)this.jm550.get(i);
	        if (!(((StoreAction)localObject).isMatch(paramBizObjClass)))
	          continue;
	        localVector.add(localObject);
	      }
	      if (localVector.size() < 1)
	      {
	        this.jm321.put(paramBizObjClass, null);
	        return null;
	      }
	    int   i = localVector.size();
	    StoreAction[] localObject = new StoreAction[i];
	      for (int j = 0; j < i; ++j)
	        localObject[j] = ((StoreAction)localVector.get(j));
	      this.jm321.put(paramBizObjClass, localObject);
	      return (StoreAction[])localObject;
	    }
   }
}